<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Get / Post 방식</title>
</head>
<body>
<h1>Get 방식과 Post 방식의 차이점</h1>
<form name="frm" action="method.jsp" method='post'>
	<input type="text" name="irum" value="park"><br/>
	<input type="text" name="address" value="seoul"><p/>
	
	취미&thinsp;선택&emsp;[
	<label><input type="checkbox" name="hobby" value="독서" />독서</label>
	<label><input type="checkbox" name="hobby" value="당구" />당구</label>
	<label><input type="checkbox" name="hobby" value="등산" />등산</label>
	<label><input type="checkbox" name="hobby" value="포샵" />포토샵</label> ]
	<br/><br/>
	
	<input type="submit" value="send">
</form>

<hr/>

<% 
request.setCharacterEncoding("utf-8");

if(request.getMethod().equals("POST")){
	out.print("이름 : " + request.getParameter("irum"));
	out.print("<br/>");
	out.print("주소 : " + request.getParameter("address"));
	
	// 체크박스로 넘어온 데이터 처리
	String[] hobby = request.getParameterValues("hobby");
	if(hobby == null){
		out.print("<li> 취미 없다");
	}else{
		for(int i=0; i<hobby.length; i++){
			out.print("<li>" + hobby[i]);
		}
	}
}
%>
<hr/>
이름 : <%=request.getParameter("irum") %><br/>
주소 : <%=request.getParameter("address") %>
<%%>
</body>
</html>